/*
 * tp_types.h
 *
 *  Created on: Aug 6, 2013
 *      Author: Thuan Nguyen
 */
#ifndef TP_TYPES_H_
#define TP_TYPES_H_

#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<netinet/in.h>


#define SYSLOG_PORT_LISTEN 514
#define DEBUG_LOG_FLAG

/*Task ID*/
#define TASK_ID_TRANSPORT 1
#define TASK_ID_APPLICATION 2
#define TASK_ID_CONTENT 3


#define SYSLOG_TRUE 1
#define SYSLOG_FALSE 0
#define SYSLOG_OK 1
#define SYSLOG_NOK 0
#define SYSLOG_NULL NULL
#define SYSLOG_SUCCESS 0 
#define SYSLOG_FAILURE -1
#define U8 char
#define U16 short int
#define U32 int
#define U64 long

/*State of Item into linked-list*/
enum item_state_t{
	ITEM_STATE_INACTIVE = 0,
	ITEM_STATE_ACTIVE
};
enum thread_action_tasklist_types_t{
	CREATE_CONNECTION = 0,
	REMOVE_CONNECTION
};
enum thread_types_t{
	MASTER_THREAD_TYPE = 0,
	SLAVE_THREAD_TYPE,
	LISTEN_THREAD_TYPE
};

typedef struct thread_info_t{
	U8 thread_type;
	pthread_t   thread_key;
	void        *thread_func;
	U8 socket_id;
	struct sockaddr_in client_addr;
}thread_info_t;

typedef struct threads_transport_t{
	U8 state_thread;
	struct threads_transport_t *p_next_threads;
	struct threads_transport_t *p_prev_threads;
	struct thread_info_t data_thread;
}threads_transport_t;

#endif

